/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controllers;

import models.Usuario;

/**
 *
 * @author Luis
 */
public class Security extends Secure.Security{
    
    public static boolean authenticate(String username, String password) {
        Usuario user = Usuario.find("byCorreo", username).first();
        return user!= null && user.password.equals(password)? true : false;
    }
    
    public static  void onAuthenticated(){
        String usuario = Security.connected();
        Usuario user = Usuario.find("byCorreo", usuario).first();
        render("Application/index.html",user);
    }
    
    public static void onDisconnected(){
        redirect("/");
    }
    
     public static void disconnect(){
        redirect("/logout");
    }
    
}
